﻿@using ClassCommon
@using ClassModel
@using ClassBLL

@{
    string requestURL = this.Request.Url.ToString();
    requestURL = requestURL.ToLower();



    ///// 解码后的taskid
    //int decodeTaskId = Convert.ToInt32(EncryptHelper.Decrypt(taskid));
    //int fileId = t_class_user_fileupalod_BLL.getFileIdWithTaskId(decodeTaskId);
    //if (fileId == -1) 
    //{
    //    // 用户没有上传excel文件
    //} 

    string taskId = ViewBag.TaskId.ToString();

    int userId = HttpCookieHelper.GetUserID();
    int decodeTaskId = Convert.ToInt32(EncryptHelper.Decrypt(ViewBag.TaskId.ToString()));
    int fileId = t_class_user_fileupalod_BLL.getFileIdWithTaskId(decodeTaskId);
    t_class_fileupload fileupload = null;
    if (fileId != 0)
    {
        fileupload = t_class_user_fileupalod_BLL.GetExcelFileWithTaskId(decodeTaskId, userId);
    }

    t_class_sections section = t_class_sections_BLL.GetSectionByTaskID(decodeTaskId);
}

<input type="hidden" id="fileId" value="@(fileId)"/>
<input type="hidden" id="sections" value="@(section != null ? "1" : "0")"/>
<!-- 文件后缀名 -->
<input type="hidden" id="extension" value="@(fileupload != null ? fileupload.extensionName : string.Empty)"/>
<div class="conLeft col-lg-2 col-md-3 col-sm-12">
    <div class="JCGZKS">
        <p class="basicInfo @(requestURL.Contains("operatorclassdetail") ? "actionsbg1" : string.Empty)"><i></i><span>基础信息</span></p>
        <p class="rule @(requestURL.Contains("ruleindex") ? "actionsbg1" : string.Empty)"><i></i><span>规则条件</span></p>
        <p class="Centralize @(requestURL.Contains("centralize") ? "actionsbg1" : string.Empty)"><i></i><span>集中排课</span></p>
        <p class="beginClass @(requestURL.Contains("beginschedule") ? "actionsbg1" : string.Empty)" ><i></i><span>开始排课</span></p>
    </div>
</div>

<script type="text/javascript">

    // actionsbg1
    $(function () {
        // 基础信息
        $(".basicInfo").on("click", function () {
            window.location.href = "/ScheduleClass/OperatorClassDetail?id=@(ViewBag.TaskId)"
        })

        //规则条件
        $(".rule").on("click", function () {
            // 要判断，是是否上传了excel数据 & 是否设置了节次。
            var fileId = $("#fileId").val();
            if (fileId == 0) {
                showFailure("您还未上传课表excel文件!");
                return;
            }

            var extension = $("#extension").val();
            if (extension == ".csv")
            {
                showFailure("csv文件功能快速开发中!");
                return;
            }


            var sections = $("#sections").val();
            if (sections == 0) {
                showFailure("您还未设置节次信息!");
                return;
            }

            window.location.href = "/ScheduleClass/ruleIndex?taskid=@(ViewBag.TaskId)";
        })

        // 集中排课
        $(".Centralize").on("click", function () {
            var fileId = $("#fileId").val();
            if (fileId == "0") {
                showFailure("您还未上传课表excel文件!");
                return;
            }

            var extension = $("#extension").val();
            if (extension == ".csv") {
                showFailure("csv文件功能快速开发中!");
                return;
            }

            var sections = $("#sections").val();
            if (sections == 0) {
                showFailure("您还未设置节次信息!");
                return;
            }

            window.location.href = "/ScheduleClass/Centralize?fileid=@(ViewBag.fileId)";// 集中排课
        })

        // 开始排课
        $(".beginClass").on("click", function () {
            var fileId = $("#fileId").val();
            if (fileId == "0") {
                showFailure("您还未上传课表excel文件!");
                return;
            }



            var sections = $("#sections").val();
            if (sections == 0) {
                showFailure("您还未设置节次信息!");
                return;
            }
            window.location.href = "/ScheduleClass/BeginSchedule?taskid=@(ViewBag.TaskId)";  // 开始排课
        })
    })

</script>
